<template>
	<view>
		<view class="" v-for="(item,index) in value" :key="index" @click="set(index,item.id)">
			<view class="">
				{{item.name}}
			</view>
		</view>
		<view class="" @click="obj1">
			{{obj.name}}
		</view>
		<view class="">
			{{obj.sex}}
		</view>

		<view class="abc">
			<view class="item item2" v-for="(item,index) in video" :key="index">
				<video :src="item" controls></video>
			</view>
			<view class="item" @click="chooseVideo">

			</view>


		</view>

		<button type="primary" @click="ab">this.$set</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				video: [],
				value: [{
					id: 1,
					name: 'a'
				}, {
					id: 2,
					name: 'b'
				}, {
					id: 3,
					name: 'c'
				}],
				obj: {
					id: 1,
					name: 'a',
					sex: '女'
				}
			}
		},
		methods: {
			chooseVideo() {
				let _self = this
				uni.chooseVideo({
					count: 1,
					sourceType: ['camera', 'album'],
					success: function(res) {
						console.log(_self.video)
						console.log(res.tempFilePath)
						_self.video.push(res.tempFilePath)
						uni.uploadFile({
							url: 'http://192.168.2.201/shop/uploads/setUploadImg', //仅为示例，非真实的接口地址
							filePath: res.tempFilePath,
							name: 'file',
							success: (res) => {
								let res1 = JSON.parse(res.data)
								
								console.log(res1.data);
								console.log(res1.data.file)
							}
						});
					}
				})
			},
			set(index, id) {
				this.$set(this.value, index + 1, {
					id: id + 1,
					name: 'doen'
				})
				console.log(this.value)
			},
			obj1() {
				this.$set(this.obj, "name", 'doen')
			},
			ab() {
				// 
				this.$set(this.obj, 'add', '中国')
				console.log(this.obj)
			}
		},
	}
</script>

<style lang="scss" scoped>
	.abc {
		display: flex;
		height: 300upx;
		.item2{
			min-width: 360upx !important;
			max-width: 360upx !important;
		}
		.item {
			flex: 1;
			min-width: 180upx;
			max-width: 180upx;
			height: 180upx;
			border: 2upx solid #999;

			video {
				width: 100%;
				height: 100%;
			}
		}
		
	}
</style>
